#include <iostream>
#include <math.h>

#include "Implement_bai8_02.h"

using namespace std;

Vector::Vector(int d = 0){
	if(d == 0){
		dimention = 0;
		value = NULL;
	}
	else
	{
		dimention = d;
		value = new int[dimention];
		for(int i = 0; i < dimention; i++){
			value[i] = rand()%10;
		}
	}
}

void Vector::operator = (const Vector& v){
	if(value){
		dimention = 0;
		delete value;
	}
	dimention = v.dimention;
	value = new int[dimention];
	for(int i = 0; i < dimention; i++)
		value[i] = v.value[i];
}

void Vector::addVec(const Vector& v){
	if(dimention != v.dimention)
		return;
	for(int i = 0; i < dimention; i++)
		value[i] += v.value[i];
}

void Vector::mulVec(Vector& v1, int k){
	for(int i = 0; i < v1.dimention; i++){
		v1.value[i] *= k; 
	}
}

void Vector::showData(){
	cout<<"v( ";
	for(int i = 0; i < dimention-1; i++)
		cout<<value[i]<<", ";
	cout<<value[dimention-1];
	cout<<" )"<<endl;
}

Vector::~Vector(){
	delete value;
}

